package com.rxz.redisdemo.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.util.StringUtils;
import redis.clients.jedis.JedisPool;
import redis.clients.jedis.JedisPoolConfig;
//@Configuration
//public class JedisConfig {
//    @Bean
//    public JedisPool jedisPool(JedisProperties jedisProperties) {
//        JedisPoolConfig config = new JedisPoolConfig();
//        config.setMaxTotal(jedisProperties.getMaxTotal());
//        config.setMaxIdle(jedisProperties.getMaxIdle());
//        config.setMinIdle(jedisProperties.getMinIdle());
//        config.setMaxWaitMillis(jedisProperties.getMaxWaitMillis());
//        config.setTestOnBorrow(jedisProperties.isTestOnBorrow());
//        config.setTestOnReturn(jedisProperties.isTestOnReturn());
//        config.setTimeBetweenEvictionRunsMillis(jedisProperties.getTimeBetweenEvictionRunsMillis());
//        config.setTestWhileIdle(jedisProperties.isTestWhileIdle());
//        config.setNumTestsPerEvictionRun(jedisProperties.getNumTestsPerEvictionRun());
//        if (StringUtils.hasText(jedisProperties.getPassword())) {
//
//            return new JedisPool(config, jedisProperties.getHost(), jedisProperties.getPort(),
//                    jedisProperties.getTimeout(), jedisProperties.getPassword());
//        }
//        return new JedisPool(config, jedisProperties.getHost(), jedisProperties.getPort(),
//                jedisProperties.getTimeout());
//    }
//}
